﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevelopStudio.Basic;
using SharpSvn;
using System.IO;
using CommonBasic = DevelopStudio.Common.Basic;
using CommonManage = DevelopStudio.Common.Manage;

namespace DevelopStudio.Control.FormPage
{
    public partial class CreateChangelist : Form
    {
        public WorkingCopyInfo WorkingCopyInfo { get; set; }

        public string ChangelistName { get; private set; }

        private List<string> changelistNames;

        public CreateChangelist()
        {
            InitializeComponent();
        }

        public CreateChangelist(WorkingCopyInfo workingCopyInfo)
        {
            InitializeComponent();
            this.WorkingCopyInfo = workingCopyInfo;
        }

        private void textBoxName_TextChanged(object sender, EventArgs e)
        {
            if (changelistNames == null)
            {
                changelistNames = WorkingCopyInfo.ChangelistInfos.Select(o => o.WorkingCopyPath).ToList();
            }

            this.ChangelistName = this.textBoxName.Text.Trim();

            if (changelistNames.Contains(this.ChangelistName) == true)
            {
                this.errorProvider1.SetError(this.textBoxName, string.Format(Properties.Resources.ErrorExistedChangelistName, this.ChangelistName));
                this.buttonOk.Enabled = false;
            }
            else
            {
                this.errorProvider1.SetError(this.textBoxName, string.Empty);
                this.buttonOk.Enabled = true;
            }
        }
    }
}
